Skip to content

Conversation

Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Jun 6, 2017

When the passed cancellation token is shared for a longer time then a single request, e.g bulkall/scrollall/reindex all spawn multiple requests over a single cancellationtoken it will leak Register() handles and memory will keep on growing because it will keep requests around indefinitely.

@Mpdreamz Mpdreamz force-pushed the fix/dispose-cancellation-token-registration branch from 85802bf to d66138b Compare June 7, 2017 21:54
@Mpdreamz Mpdreamz requested a review from russcam June 12, 2017 12:20
Copy link
Contributor

@russcam russcam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - just one question on what should be included in the using block.

I don't think await GetResponseAsync(requestData, request, builder); needs to be wrapped in the using as cancellation of the request is handled by RegisterApmTaskTimeout()


if (data != null)
var request = this.CreateHttpWebRequest(requestData);
using (cancellationToken.Register(() => request.Abort()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also need to include await GetResponseAsync(requestData, request, builder); in the using block?

Copy link
Member Author

@Mpdreamz Mpdreamz Jun 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right i think it does

@Mpdreamz
Copy link
Member Author

@forloop updated with one more commit mind giving this another review? 👍

Mpdreamz added 3 commits June 21, 2017 09:30
… single request, e.g bulkall/scrollall/reindex it will leak Register() handles and memory will keep on growing
…ely cancel on the waithandles in the case of exceptions too
@Mpdreamz Mpdreamz force-pushed the fix/dispose-cancellation-token-registration branch from 47afefc to fd2cc93 Compare June 21, 2017 07:31
@Mpdreamz Mpdreamz merged commit c86015a into 5.x Jun 21, 2017
Mpdreamz added a commit that referenced this pull request Jun 21, 2017
* When the passed cancellation token is shared for a longer time then a single request, e.g bulkall/scrollall/reindex it will leak Register() handles and memory will keep on growing

* PostRequestAsync does not need to be generic

* include GetResponse() in using and inlined it so we can more aggresively cancel on the waithandles in the case of exceptions too
Mpdreamz added a commit that referenced this pull request Jun 21, 2017
…hat now needs forward porting again to 5.x master cc @russcam
Mpdreamz added a commit that referenced this pull request Jun 21, 2017
…e begin/end getrequeststream apm task wait handler relates to #2776
Mpdreamz added a commit that referenced this pull request Jun 21, 2017
…e begin/end getrequeststream apm task wait handler relates to #2776
@Mpdreamz Mpdreamz deleted the fix/dispose-cancellation-token-registration branch June 21, 2017 08:38
@Mpdreamz
Copy link
Member Author

@russcam spotted an opportunity to clean up the code while manually merging to 2.x forward ported these to master and 5x too (see attached commits).

@russcam
Copy link
Contributor

russcam commented Jun 26, 2017

Nice!

awelburn pushed a commit to Artesian/elasticsearch-net that referenced this pull request Nov 6, 2017
* When the passed cancellation token is shared for a longer time then a single request, e.g bulkall/scrollall/reindex it will leak Register() handles and memory will keep on growing

* PostRequestAsync does not need to be generic

* include GetResponse() in using and inlined it so we can more aggresively cancel on the waithandles in the case of exceptions too
awelburn pushed a commit to Artesian/elasticsearch-net that referenced this pull request Nov 6, 2017
…e begin/end getrequeststream apm task wait handler relates to elastic#2776
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants